<?php

use yii\helpers\Html;
use yii\grid\GridView;
use backend\models\EduUser;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\EduDotSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Edu Dots';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="edu-dot-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('Create Edu Dot', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'user.id',
            'user.nickname',
//            'user.avatar_url',
            [
                'attribute' => 'user.avatar_url',
                'enableSorting' => false,
                'format' => ['image', [
                    'width' => '80',
                    'height' => '80',
                ]],
            ],
            'room_name',
            'rank',
            'user.parent_id',
            [
                'label' => '推荐教室|二级教室',
                'format' => 'raw',
                'value' => function ($model) {
                    $count = EduUser::parentCount($model->user_id);
                    return '(' . $count . ')' . Html::a('查看下级', ['edu-dot/index', 'EduDotSearch[parent_id]' => $model->user_id], ['class' => '']);
                }
            ],
            [
                'label' => '门店总收入',
                'attribute' => 'total_fee',
                'format' => 'html',
                'value' => function ($model, $key, $index) {
                    return $model->total_fee . '-' . Html::a('查看收入详情', ['edu-income/index', 'EduIncomeSearch[get_user_id]' => $model->user_id], ['class' => '']);
                }
            ],
            //'label_one',
            //'label_two',
            //'label_three',
            //'code',
            //'parent_code',
            //'room_images:ntext',
            //'room_teacher:ntext',
            //'room_address',
            //'gradution_count',
            //'gradution_base',
            //'video_fee',
            //'room_fee',
            //'total_fee',
            //'put_money',
            //'sort',
            //'rank',
            //'status',
            //'create_time:datetime',
            //'latitude',
            //'longitude',
            //'collect_count',
            //'collect_base',
            //'room_des',
            //'show_image:ntext',
            //'update_time:datetime',
            //'openid',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
<?php
$script = <<< JS
    $(".pagination").append('&nbsp;跳转<input id="invalue" type="text" style="border-radius: 5px;outline: none;border: solid 1px #dddddd;width: 52px;height: 34px;text-align: center;" class="pane"/>页&nbsp;<button id="skip" class="btn btn-default skip ok"">确定</button>');
    
    $('#skip').click(function() {
        var page = $('#invalue').val();
        location.href = "index.php?r=edu-dot/index&page="+ page;
    });
JS;
$this->registerJs($script);
?>
